package com.lh.mybatisuse.service.Impl;

import com.lh.mybatisuse.service.SendExceptionService;
import com.lh.mybatisuse.unit.GetPropertiesClass;
import com.lh.mybatisuse.unit.SendToRabbitMQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.logging.Logger;

/**
 * @author lianghao
 * @create 2019-12-15 15:07
 */
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Service
public class SendExceptionServiceImpl implements SendExceptionService {
    @Autowired
    GetPropertiesClass getPropertiesClass;
    @Autowired
    SendToRabbitMQ sendToRabbitMQ;
    private Logger logger;

    public SendExceptionServiceImpl() {
        this.logger = Logger.getLogger("Rabbit Send");
    }

    @Override
    public void sendException(Exception exception, String authorityName) {
        sendPriException(exception, authorityName, null);
    }

    @Override
    public void sendException(Exception exception, String authorityName, String remark) {
        sendPriException(exception, authorityName, remark);
    }

    private void sendPriException(Exception exception, String authorityName, String remark) {
//        if (getPropertiesClass.getThrowExceptionSign()) {
//            ExceptionMqModel exceptionMqModel = new ExceptionMqModel(
//                    getPropertiesClass.getApplicationName()
//                    , getPropertiesClass.getPort()
//                    , getPropertiesClass.getVersion()
//                    , remark
//                    , authorityName
//                    , exception);
//            if (!sendToRabbitMQ.sendToRabbitMQ(exceptionMqModel, ExceptionMqModel.class)) {
//                logger.info("MQ发送失败");
//            }
//        }
    }

}
